#!/usr/bin/python

import subprocess
from configparser import GKVMConfigParser

class GKVMLauncher:

	def __init__(self):
		"""docstring for __init__"""
		self.config = GKVMConfigParser()

	def startMachineById(self, id):
		m_d       = self.config.getDataById(id)
		arguments = ['kvm', '-hda', m_d['disk'], '-net', 'nic', '-net', m_d['network']]

		if m_d['session'] == '0':
			arguments.append('-nographic')
	
		ret_val = subprocess.call( arguments )

	def startMachineByName(self, name):
                m_d       = self.config.getDataByName(name))
                arguments = ['kvm', '-hda', m_d['disk'], '-net', 'nic', '-net', m_d['network']]

                if m_d['session'] == '0':
                        arguments.append('-nographic')

                ret_val = subprocess.call( arguments )
		
